# In our example, we draw randomly 2000 red points on the client area.

import sys, random
from PySide import QtGui, QtCore

class Window(QtGui.QWidget):
    def __init__(self):
        super(Window, self).__init__()

    # Drawing is done within a paintEvent
    def paintEvent(self, event):
        # QtGui.QPainter class is responsible for all the low level painting. All the painting event go between begin()
        # and the end() methods. The actual painting in this program is delegated to the 'drawText' method
        painter = QtGui.QPainter()
        painter.begin(self)
        self.drawPoints(event, painter)
        painter.end()

        self.setGeometry(200, 200, 300, 200)
        self.setWindowTitle("Drawing-Points")

    def drawPoints(self, event, painter):
        painter.setPen(QtGui.QColor(168, 34, 3))
        size = self.size()
        for i in range(2000):
            x = random.randint(1, size.width() - 1)
            y = random.randint(1, size.height() - 1)
            painter.drawPoint(x, y)



if __name__ == "__main__":
    appObject = QtGui.QApplication(sys.argv)
    ex = Window()
    ex.show()
    sys.exit(appObject.exec_())

